package com.mobile.tools.cfg;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.PersistentClass;
import org.springframework.orm.hibernate3.LocalSessionFactoryBean;

public class SessionFactoryUtil {
	private SessionFactory sessionFactory;
	
	private LocalSessionFactoryBean localSessionFactoryBean;
	
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public void setLocalSessionFactoryBean(
			LocalSessionFactoryBean localSessionFactoryBean) {
		this.localSessionFactoryBean = localSessionFactoryBean;
	}
	/**
	 * 获取SessionFactory的configuration
	 * @return
	 */
	public Configuration getConfiguration(){
		return this.localSessionFactoryBean.getConfiguration();
	}
	/**
	 * 获取映射中的实体类
	 * @param entityName		实体名称
	 * @return
	 */
	public PersistentClass getClassMapping(String entityName){
		return getConfiguration().getClassMapping(entityName);
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public LocalSessionFactoryBean getLocalSessionFactoryBean() {
		return localSessionFactoryBean;
	}

	public SessionFactoryUtil(SessionFactory sessionFactory,
			LocalSessionFactoryBean localSessionFactoryBean) {
		super();
		this.sessionFactory = sessionFactory;
		this.localSessionFactoryBean = localSessionFactoryBean;
	}

	public SessionFactoryUtil() {
		super();
	}
	
	/**
     *  return hibernate configuration
     *
     *//*
	public Configuration getConfiguration() {
		return this.sessionFactory.getC;
	}*/
	
}
